package sever

import (
	"gitee.com/enjoy_5/sigin-rpc/internal/model"
	"gitee.com/enjoy_5/sigin-rpc/proto/points"
)

func CreatePoints(in *points.CreatePointsReq) (*model.Points, error) {
	stu := model.Points{
		UserId:        in.UserId,
		Username:      in.Username,
		PointsBalance: in.PointsBalance,
	}
	err := stu.CreatePoints()
	if err != nil {
		return nil, err
	}
	return &stu, err
}
func GetPoints(in *points.GetPointsReq) ([]*model.Points, error) {
	res := model.Points{
		UserId:        in.UserId,
		Username:      in.Username,
		PointsBalance: in.PointsBalance,
	}
	stu, err := res.GetPoints()
	if err != nil {
		return nil, err
	}
	return stu, err
}
func UpdatePoints(in *points.UpdatePointsReq) (*model.Points, error) {
	stu := model.Points{
		UserId:        in.UserId,
		PointsBalance: in.PointsBalance,
	}
	_, err := stu.UpdatePoints()
	if err != nil {
		return nil, err
	}
	return &stu, err
}
